package cn.smxy.ln;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author ln
 * @date 2022年05月20日 20:04
 * 启动类
 */
@SpringBootApplication
// @EnableEurekaClient 开启Eureka客户端注解，在服务启动后自动向注册中心注册服务
@EnableEurekaClient
// @EnableDiscoveryClient 开启服务发现客户端的注解，可以用来获取一些配置的信息，得到具体的微服务
@EnableDiscoveryClient
@EnableCircuitBreaker // 添加对熔断的支持注解
@EnableTransactionManagement  // 开启springboot 对数据库事务的支持
@MapperScan("cn.smxy.ln.mapper")
public class Provider_workregister_hystrix_8010 {
    public static void main(String[] args) {
        SpringApplication.run(Provider_workregister_hystrix_8010.class, args);
    }

    //http://localhost:9010/hystrix
    //增加一个 Servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        //访问该页面就是监控页面
        //http://localhost:8010/actuator/workregister.stream
        registrationBean.addUrlMappings("/actuator/workregister.stream");
        return registrationBean;
    }
}
